package com.fs.controller;

import com.fs.common.Result;
import com.fs.common.UploadUtils;
import com.fs.pojo.Videos;
import com.fs.service.VideosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class VideosController {

    @Autowired
    private VideosService videosService;
    //完成视频上传
    @RequestMapping("/uploadVideo")
    public Result uploadVideo(String userId, MultipartFile file){
        //file代表上传的文件
        String videoPathDB= UploadUtils.uploadVideo(userId,file);
        return Result.ok(videoPathDB);
    }
    @RequestMapping("/saveVideo")
    public Result saveVideo(@RequestBody Videos videos){
            videosService.saveVideo(videos);
            return Result.ok();
    }
}
